package com.mdb.open.trade.service.trade;


/*
* Copyright (C), 2017-2019 澳发科技(MDB)
* FileName: TfMerchantInfoService.java
* Author:   you.yichao
* Date:     2019-08-22
* History:
* <author>          <time>          <version>          <desc>
* you.yichao         2019-08-22          V1.00             代码生成器初始生成代码
* -----------------------------------------------------------
* 作者姓名           修改时间           版本号            描述
*/


import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mdb.bc.api.data.ResultEx;
import com.mdb.bc.database.mybatisplus.SuperService;
import com.mdb.open.trade.common.MdbDataSource;
import com.mdb.open.trade.domain.po.trade.MerchantInfo;
import com.mdb.open.trade.mapper.trade.TfMerchantInfoMapper;
import org.springframework.stereotype.Service;

/**
 * 类描述：
 *  商户信息 服务类
 *
 * @author you.yichao
 * @date 2019-08-22
 */
@Service
@DS(MdbDataSource.TRADE)
public class TfMerchantInfoService extends SuperService<TfMerchantInfoMapper, MerchantInfo> {

    public ResultEx<MerchantInfo> getMerchantInfo(String customerCode, String merchantNo) {

        LambdaQueryWrapper<MerchantInfo> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(MerchantInfo::getCustomerCode, customerCode);
        queryWrapper.eq(MerchantInfo::getMerchantNo, merchantNo);

        return ResultEx.ok(this.baseMapper.selectOne(queryWrapper));
    }

    public ResultEx<MerchantInfo> getCustomerInfo(String customerCode) {

        LambdaQueryWrapper<MerchantInfo> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(MerchantInfo::getCustomerCode, customerCode);
        queryWrapper.last("limit 1");
        return ResultEx.ok(this.baseMapper.selectOne(queryWrapper));
    }

}
